package com.youdoneed.common.util;

import java.util.UUID;

/**
 * Created by Administrator on 2018/1/23 0023.
 */
public class StringUuidUtil {
    /**
     *    * 随机生成UUID
     *    * @return
     *    
     */
    public static String getUUID() {
        UUID id = UUID.randomUUID();
        // 取高低位转换成16进制 比直接toString效率好很多
        StringBuilder mb = new StringBuilder(Long.toHexString(id.getMostSignificantBits()));
        while (mb.length() < 16) {
            mb.insert(0, '0');
        }
        StringBuilder lb = new StringBuilder(Long.toHexString(id.getLeastSignificantBits()));
        while (lb.length() < 16) {
            lb.insert(0, '0');
        }
        return mb.append(lb).toString();
    }
}
